package com.dingding.service.usermangerservice.impl;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.bean.databean.request.ReqAddUserRoute;
import com.dingding.bean.databean.request.ReqDeleteUserRoute;
import com.dingding.bean.databean.request.ReqUpdateUserRoute;
import com.dingding.bean.databean.request.ReqUserRouteList;
import com.dingding.bean.databean.request.ReqUserRouteStatus;
import com.dingding.bean.databean.request.ReqUserpushSetting;
import com.dingding.bean.databean.request.ReqgetUserpush;
import com.dingding.bean.databean.response.DataResponse;
import com.dingding.bean.databean.response.ResgetUserpush;
import com.dingding.bean.entity.Userdetail;
import com.dingding.bean.entity.Userpushsetting;
import com.dingding.bean.entity.Userroute;
import com.dingding.common.core.config.SystemCode;
import com.dingding.common.core.util.GetDistanceUtil;
import com.dingding.common.core.util.ToolUtil;
import com.dingding.common.core.util.dto.CalculatDistanceDTO;
import com.dingding.service.BaseService;
import com.dingding.service.usermangerservice.IUserRouteService;

@SuppressWarnings("all")
public class UserRouteServiceImpl extends BaseService implements IUserRouteService {

	private Logger log = Logger.getLogger(this.getClass());

	/**
	 * @Title: addUserRoute @Description: 添加用户路线 @param reqAddUserRoute
	 *         客户端请求添加路线bean @param dataResponse 响应数据 @author Li
	 *         Yi @return @throws
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public void addUserRoute(ReqAddUserRoute reqAddUserRoute, DataResponse dataResponse) {

		boolean flag = this.validateUserRoute(reqAddUserRoute);
		// 判断客户端参数是否为空
		if (!flag) {
			setStatus(dataResponse, SystemCode.DATA_NULL_ERROR);
			return;
		}

		// 计算添加起点和终点的距离
		CalculatDistanceDTO calculatDistanceDTO = GetDistanceUtil.getSingleDistance(reqAddUserRoute.getStartLongitude(),
				reqAddUserRoute.getStartLatitude(), reqAddUserRoute.getPurposeLongitude(),
				reqAddUserRoute.getPurposeLatitude());

		// 判断起点和终点的距离是否小于一公里
		if (calculatDistanceDTO.getDistance().compareTo(new BigDecimal(1)) < 0) {
			setStatus(dataResponse, SystemCode.DISTANCE_SHORT_ERROR);
			return;
		}

		List<Userroute> list = null;

		Criterion criterion = Restrictions.eq("loginId", reqAddUserRoute.getUserId());

		Userdetail userdetail = null;

		try {
			userdetail = super.userDetailDao.queryCriteriaUnResult(criterion, false);
		} catch (Exception e2) {
			log.info("用户详情读取错误,类:" + this.getClass() + e2);
			return;
		}
		// 获取用户路线
		try {
			list = super.userRouteDao.queryCriteriaList(criterion, false);
		} catch (Exception e1) {
			log.info("用户路线读取错误,类:" + this.getClass() + e1);
			return;
		}

		// 如果路线表为空，将详情表地址信息添加至用户路线表中(2条)
		if (list == null) {
			firstAdd(reqAddUserRoute.getUserId(), userdetail, dataResponse, list);
			return;
		}
		// 判断用户数量是否还能继续添加(大于四条无法继续添加)
		if (list != null && list.size() >= 4) {
			setStatus(dataResponse, SystemCode.ADD_USER_ROUTE);
			return;
		}

		// 添加用户路线
		try {
			super.userRouteDao.addUserRoute(reqAddUserRoute);
		} catch (Exception e) {
			log.info("用户路线添加异常,类" + this.getClass(), e);
			setStatus(dataResponse, SystemCode.ERROR);
			return;
		}
		setStatus(dataResponse, SystemCode.SUCCESS);

	}

	/**
	 * @Title: updateUserRoute @Description: 修改用户路线 @param reqUpdateUserRoute
	 *         客户端请求修改路线bean @param dataResponse 响应数据 @author Li
	 *         Yi @return @throws
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public void updateUserRoute(ReqUpdateUserRoute reqUpdateUserRoute, DataResponse dataResponse) {

		boolean flag = this.validateUserRoute(reqUpdateUserRoute);
		// 判断客户端请求参数是否为空
		if (!flag) {
			setStatus(dataResponse, SystemCode.DATA_NULL_ERROR);
			return;
		}

		// 计算添加起点和终点的距离
		CalculatDistanceDTO calculatDistanceDTO = GetDistanceUtil.getSingleDistance(
				reqUpdateUserRoute.getStartLongitude(), reqUpdateUserRoute.getStartLatitude(),
				reqUpdateUserRoute.getPurposeLongitude(), reqUpdateUserRoute.getPurposeLatitude());

		// 判断起点和终点的距离是否小于一公里
		if (calculatDistanceDTO.getDistance().compareTo(new BigDecimal(1)) < 0) {
			setStatus(dataResponse, SystemCode.DISTANCE_SHORT_ERROR);
			return;
		}

		// 声明用户详情Bean
		Userdetail userdetail = null;

		List<Userroute> userRoutes = null;
		// 根据路线ID查询路线信息，并进行更新

		Criterion criterion = Restrictions.eq("loginId", reqUpdateUserRoute.getUserId());

		try {
			// 获取该用户全部路线
			userRoutes = super.userRouteDao.queryCriteriaList(criterion, false);

			// 获取用户详情
			userdetail = super.userDetailDao.queryCriteriaUnResult(criterion, false);

			// 判断该用户是否存在路线信息
			if (userRoutes != null && userRoutes.size() > 0) {

				// 遍历该用户全部路线
				for (Userroute userRoute : userRoutes) {

					// 判断路线类型是否为空
					if (userRoute.getRouteType() == null || (!userRoute.getUrId().equals(reqUpdateUserRoute.getUrId())
							&& reqUpdateUserRoute.getRouteType() == 3)) {
						continue;
					}

					// 修改路线信息
					super.userRouteDao.updateUserRoute(reqUpdateUserRoute, userRoute);

					// 如果修改的其他路线，则只修改自身
					if (userRoute.getRouteType() == 3) {
						break;
					}
				}

				if (userdetail != null) {

					Date date = new SimpleDateFormat("HH:mm").parse(reqUpdateUserRoute.getSetOutTime());

					if (reqUpdateUserRoute.getRouteType() == 1) {
						userdetail.setHomeAddress(reqUpdateUserRoute.getStartAddress());// 家地址
						userdetail.setHomeLongitude(reqUpdateUserRoute.getStartLongitude());// 家经度
						userdetail.setHomeLatitude(reqUpdateUserRoute.getStartLatitude());// 家纬度
						userdetail.setCompanyAddress(reqUpdateUserRoute.getPurposeAddress());// 公司地址
						userdetail.setCompanyLongitude(reqUpdateUserRoute.getPurposeLongitude());// 公司经度
						userdetail.setCompanyLatitude(reqUpdateUserRoute.getPurposeLatitude());// 公司纬度
						userdetail.setStartworkTime(date);// 上班时间
					} else if (reqUpdateUserRoute.getRouteType() == 2) {
						userdetail.setHomeAddress(reqUpdateUserRoute.getPurposeAddress());// 家地址
						userdetail.setHomeLongitude(reqUpdateUserRoute.getPurposeLongitude());// 家经度
						userdetail.setHomeLatitude(reqUpdateUserRoute.getPurposeLatitude());// 家纬度
						userdetail.setCompanyAddress(reqUpdateUserRoute.getStartAddress());// 公司地址
						userdetail.setCompanyLongitude(reqUpdateUserRoute.getStartLongitude());// 公司经度
						userdetail.setCompanyLatitude(reqUpdateUserRoute.getStartLatitude());// 公司纬度
						userdetail.setEndworkTime(date);// 下班时间
					}

				}

			}

		} catch (Exception e) {
			log.info("更新用户路线出现异常,类：" + this.getClass(), e);
			setStatus(dataResponse, SystemCode.ERROR);
			return;
		}
		setStatus(dataResponse, SystemCode.SUCCESS);

	}

	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public void deleteUserRoute(ReqDeleteUserRoute reqDeleteUserRoute, DataResponse dataResponse) {
		// 判断客户端请求参数是否为空
		if (ToolUtil.isBlank(reqDeleteUserRoute.getUrId()) || ToolUtil.isBlank(reqDeleteUserRoute.getUserId())) {
			setStatus(dataResponse, SystemCode.DATA_NULL_ERROR);
			return;
		}

		Userroute userroute = null;
		// 删除根据路线ID查询到的路线
		try {
			userroute = super.userRouteDao.getById(reqDeleteUserRoute.getUrId(), false);

			if (userroute != null) {

				if (userroute.getRouteType() != 1 && userroute.getRouteType() != 2) {
					super.userRouteDao.deleteUserRoute(userroute);
				} else {
					setStatus(dataResponse, SystemCode.ROUTE_NOT_CAN_DELETE);
					return;
				}
			} else {
				setStatus(dataResponse, SystemCode.DATA_NULL_ERROR);
				return;
			}

		} catch (Exception e) {
			log.info("删除用户路线异常,类:" + this.getClass(), e);
			setStatus(dataResponse, SystemCode.ERROR);
			return;
		}

		setStatus(dataResponse, SystemCode.SUCCESS);

	}

	/**
	 * @Title: getUserRouteList @Description: 获取路线接口 @param userId 用户Id @param
	 *         dataResponse 响应数据 @author Li Yi @return @throws
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public void getUserRouteList(ReqUserRouteList reqUserRouteList, DataResponse dataResponse) {

		// 判断客户端参数是否为空
		if (ToolUtil.isBlank(reqUserRouteList.getUserId())) {
			log.info("客户端请求参数为空" + this.getClass());
			setStatus(dataResponse, SystemCode.DATA_NULL_ERROR);
			return;
		}

		String userId = reqUserRouteList.getUserId();

		// 判断地址是否进行过设置
		Criterion criterion = Restrictions.eq("loginId", userId);

		Userpushsetting userpushsetting = null;

		try {
			userpushsetting = super.userpushSettingDao.queryCriteriaUnResult(criterion, false);
		} catch (Exception e1) {
			log.info("用户推送设置获取失败", e1);
			return;
		}

		if (userpushsetting == null) {
			userpushsetting = new Userpushsetting();
			userpushsetting.setLoginId(userId);
			userpushsetting.setUopsId(ToolUtil.getUid());
			userpushsetting.setOrderReminder(1);
			userpushsetting.setWeekendPush(1);
			userpushsetting.setRegularRouteConditions(1);
			super.userpushSettingDao.save(userpushsetting);
		}

		List<Userroute> list = null;
		// 获取该用户所有用户路线
		try {
			list = super.userRouteDao.getUserRouteList(userId);
		} catch (Exception e) {
			log.info("用户路线获取异常，类" + this.getClass(), e);
			setStatus(dataResponse, SystemCode.ERROR);
			return;
		}

		if (list == null) {
			list = new ArrayList<Userroute>();
		}
		dataResponse.setResponseBody(list);
		dataResponse.setResponseNumber("HH:mm");
		setStatus(dataResponse, SystemCode.SUCCESS);
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public void isRouteEnable(ReqUserRouteStatus reqUserRouteStatus, DataResponse dataResponse) {
		// 判断客户端参数是否为空
		if (reqUserRouteStatus == null || ToolUtil.isBlank(reqUserRouteStatus.getUrId())
				|| ToolUtil.isBlank(reqUserRouteStatus.getUserId()) || reqUserRouteStatus.getIsEnable() == null) {
			log.info("客户端请求参数为空" + this.getClass());
			setStatus(dataResponse, SystemCode.DATA_NULL_ERROR);
			return;
		}

		Userroute userroute = null;
		// 查找用户路线
		try {
			userroute = super.userRouteDao.getById(reqUserRouteStatus.getUrId(), false);
		} catch (Exception e) {
			log.info("获取用户路线失败" + this.getClass(), e);
			setStatus(dataResponse, SystemCode.ERROR);
			return;
		}
		// 判断路线是否存在，若存在，将启用状态保存
		if (userroute != null) {
			userroute.setIsEnable(reqUserRouteStatus.getIsEnable());
			setStatus(dataResponse, SystemCode.SUCCESS);
			return;
		}
		setStatus(dataResponse, SystemCode.USER_ROUTE_NOT_EXIST);

	}

	/**
	 * @Title: validateUserRoute @Description: 验证设置的路线地址是否为空 @param
	 *         reqResetAddress 客户端传入参数是否为空 @return true 参数正确 false 参数错误 @throws
	 */
	public boolean validateUserRoute(ReqAddUserRoute reqAddUserRoute) {
		if (reqAddUserRoute == null || ToolUtil.isBlank(reqAddUserRoute.getUserId())
				|| reqAddUserRoute.getSetOutTime() == null || ToolUtil.isBlank(reqAddUserRoute.getStartAddress())
				|| ToolUtil.isBlank(reqAddUserRoute.getPurposeAddress()) || reqAddUserRoute.getStartLongitude() == null
				|| reqAddUserRoute.getStartLatitude() == null || reqAddUserRoute.getPurposeLongitude() == null
				|| reqAddUserRoute.getPurposeLatitude() == null) {
			return false;
		}

		return true;
	}

	/**
	 * @Title: validateUserRoute @Description: 验证设置的路线地址是否为空 @param
	 *         reqResetAddress 客户端传入参数是否为空 @return true 参数正确 false 参数错误 @throws
	 */
	public boolean validateUserRoute(ReqUpdateUserRoute reqUpdateUserRoute) {
		if (reqUpdateUserRoute == null || ToolUtil.isBlank(reqUpdateUserRoute.getUserId())
				|| ToolUtil.isBlank(reqUpdateUserRoute.getUrId()) || reqUpdateUserRoute.getSetOutTime() == null
				|| reqUpdateUserRoute.getRouteType() == null || ToolUtil.isBlank(reqUpdateUserRoute.getStartAddress())
				|| ToolUtil.isBlank(reqUpdateUserRoute.getPurposeAddress())
				|| reqUpdateUserRoute.getStartLongitude() == null || reqUpdateUserRoute.getStartLatitude() == null
				|| reqUpdateUserRoute.getPurposeLongitude() == null
				|| reqUpdateUserRoute.getPurposeLatitude() == null) {
			return false;
		}

		return true;
	}

	/**
	 * 
	 * @Title: setStatus @Description:根据状态码设置响应信息 @param dataResponse
	 *         响应信息封装bean @param status 状态码 @author Li Yi @return void @throws
	 */
	public void setStatus(DataResponse dataResponse, int status) {
		String message = null;
		switch (status) {
		case SystemCode.SUCCESS:// 请求成功
			message = SystemCode.SUCCESS_MESSAGE;
			break;
		case SystemCode.VALIDATE_THROUGH_ERROR:// 手机验证码失效
			message = SystemCode.VALIDATE_THROUGH_MESSAGE;
			break;
		case SystemCode.ERROR:// 系统异常
			message = SystemCode.ERROR_MESSAGE;
			break;
		case SystemCode.DATA_NULL_ERROR:// 客户端请求数据为空
			message = SystemCode.DATA_NULL_MESSAGE;
			break;
		case SystemCode.DATA_NULL_PARAM:// 客户端请求参数为空
			message = SystemCode.DATA_NULL_PARAM_MESSAGE;
			break;
		case SystemCode.REGISTER_USER_EXIST_ERROR:// 用户已存在
			message = SystemCode.REGISTER_USER_EXIST_MESSAGE;
			break;
		case SystemCode.USER_INFO_NOT_EXIST_ERROR:// 用户不存在
			message = SystemCode.USER_INFO_NOT_EXIST_MESSAGE;
			break;
		case SystemCode.PHONE_NUM_NOT_MATCH_ERROR:// 手机格式不正确
			message = SystemCode.PHONE_NUM_NOT_MATCH_MESSAGE;
			break;
		case SystemCode.USER_ROUTE_NOT_EXIST:// 用户路线不存在
			message = SystemCode.USER_ROUTE_NOT_EXIST_MESSAGE;
		case SystemCode.ADDRESS_NOT_SET:// 地址未设置
			message = SystemCode.ADDRESS_NOT_SET_MESSAGE;
			break;
		case SystemCode.ADD_USER_ROUTE:// 用户路线不能大于四条
			message = SystemCode.ADD_USER_ROUTE_MESSAGE;
			break;
		case SystemCode.ROUTE_NOT_CAN_DELETE:// 该路线不能删除
			message = SystemCode.ROUTE_NOT_CAN_DELETE_MESSAGE;
			break;
		case SystemCode.DISTANCE_SHORT_ERROR:// 距离过短
			message = SystemCode.DISTANCE_SHORT_ERROR_MESSAGE;
			break;
		}

		dataResponse.setResponseCode(status);
		dataResponse.setResponseMessage(message);
	}

	/**
	 * 
	 * @throws ParseException
	 * @Title: setFirstRoute @Description:第一次根据地址设置路线 @param dataResponse
	 *         响应信息封装bean @param status 状态码 @author Li Yi @return void @throws
	 */
	public List<Userroute> setFirstRoute(Userroute userroute, Userroute userroute_return, List<Userroute> list,
			String userId, Userdetail userdetail) throws ParseException {
		// 路线Id
		userroute.setUrId(ToolUtil.getUid());
		// 用户Id
		userroute.setLoginId(userId);

		// SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
		// String dateStr =
		// userdetail.getStartworkTime().toString().substring(11, 19);
		// ParsePosition pos = new ParsePosition(4);
		// Date datego = formatter.parse(dateStr,pos);
		// //时间(上班时间)
		// SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
		// String dateStr = format.format(userdetail.getStartworkTime());
		// Date date = format.parse(dateStr);
		// userroute.setSetOutTime(date);
		userroute.setSetOutTime(userdetail.getStartworkTime());
		// userroute.setSetOutTime(userdetail.getStartworkTime());
		// 出发地址
		userroute.setStartAddress(userdetail.getHomeAddress());
		// 目的地址
		userroute.setPurposeAddress(userdetail.getCompanyAddress());
		// 出发经度
		userroute.setStartLongitude(userdetail.getHomeLongitude());
		// 出发纬度
		userroute.setStartLatitude(userdetail.getHomeLatitude());
		// 目的经度
		userroute.setPurposeLongitude(userdetail.getCompanyLongitude());
		// 目的纬度
		userroute.setPurposeLatitude(userdetail.getCompanyLatitude());
		// 路线类型(1:上班 2:下班3:附近)
		userroute.setRouteType(1);
		// 启用状态
		userroute.setIsEnable(1);

		// 路线ID
		userroute_return.setUrId(ToolUtil.getUid());
		// 用户ID
		userroute_return.setLoginId(userId);
		//// SimpleDateFormat formatter2 = new SimpleDateFormat("HH:mm:ss");
		// String dateStr2 =
		//// userdetail.getStartworkTime().toString().substring(11, 19);
		// ParsePosition pos2 = new ParsePosition(4);
		// Date dateback = formatter2.parse(dateStr2,pos2);
		// 时间(下班时间)
		userroute_return.setSetOutTime(userdetail.getEndworkTime());
		// 出发地址
		userroute_return.setStartAddress(userdetail.getCompanyAddress());
		// 目的地址
		userroute_return.setPurposeAddress(userdetail.getHomeAddress());
		// 出发经度
		userroute_return.setStartLongitude(userdetail.getCompanyLongitude());
		// 出发纬度
		userroute_return.setStartLatitude(userdetail.getCompanyLatitude());
		// 目的经度
		userroute_return.setPurposeLongitude(userdetail.getHomeLongitude());
		// 目的纬度
		userroute_return.setPurposeLatitude(userdetail.getHomeLatitude());
		// 路线类型(1:上班 2:下班3:附近)
		userroute_return.setRouteType(2);
		// 启用状态
		userroute_return.setIsEnable(1);

		// 路线Userroute对象添加至list中
		list.add(userroute);
		list.add(userroute_return);

		return list;
	}

	public void firstAdd(String userId, Userdetail userdetail, DataResponse dataResponse, List<Userroute> list) {
		// 第一次将往返地址设置为路线
		Userroute userroute = new Userroute();
		Userroute userroute_return = new Userroute();

		try {
			list = this.setFirstRoute(userroute, userroute_return, list, userId, userdetail);
		} catch (ParseException e1) {
			log.info("日期转换异常或设置通勤路线异常", e1);
			return;
		}

		try {
			super.userRouteDao.save(userroute);
			super.userRouteDao.save(userroute_return);
		} catch (Exception e) {
			log.info("第一次存储用户路线失败,类" + this.getClass(), e);
			setStatus(dataResponse, SystemCode.ERROR);
			return;
		}

		dataResponse.setResponseBody(list);
		dataResponse.setResponseNumber("HH:mm");
		setStatus(dataResponse, SystemCode.SUCCESS);
	}

	/**
	 * @Title:updateUserpushSetting
	 * @description:更新推送设置
	 * @param reqUserpushSetting 路线设置请求bean
	 * @param dataResponse 响应
	 * @author yi
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public void updateUserpushSetting(ReqUserpushSetting reqUserpushSetting, DataResponse dataResponse) {
		// 判断客户端请求参数是否为空
		if (reqUserpushSetting == null || ToolUtil.isBlank(reqUserpushSetting.getUserId())
				|| reqUserpushSetting.getOrderReminder() == null || reqUserpushSetting.getWeekendPush() == null
				|| reqUserpushSetting.getRegularRouteConditions() == null) {
			log.info("客户端请求数据为空" + this.getClass() + "updateUserpushSetting()");
			setStatus(dataResponse, SystemCode.DATA_NULL_ERROR);
			return;
		}

		// 更新路线推送设置
		super.userpushSettingDao.updateuserpushSetting(reqUserpushSetting, dataResponse);

		setStatus(dataResponse, SystemCode.SUCCESS);
	}

	/**
	 * @Title:getUserpushSetting
	 * @description:获取推送设置
	 * @param reqgetUserpush 获取路线设置请求bean
	 * @param dataResponse 响应
	 * @author yi
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public void getUserpushSetting(ReqgetUserpush reqgetUserpush, DataResponse dataResponse) {
		// 客户端请求数据为空
		if (reqgetUserpush == null || ToolUtil.isBlank(reqgetUserpush.getUserId())) {
			log.info("客户端请求数据为空" + this.getClass());
			return;
		}

		Criterion criterion = Restrictions.eq("loginId", reqgetUserpush.getUserId());

		Userpushsetting userpushsetting = null;
		try {// 获取用户推送设置状态
			userpushsetting = super.userpushSettingDao.queryCriteriaUnResult(criterion, false);
		} catch (Exception e) {
			log.info("获取用户路线推送信息失败", e);
			return;
		}
		// 对用户推送设置信息进行获取，并封装为响应bean
		if (userpushsetting == null){
			userpushsetting = new Userpushsetting();
			userpushsetting.setLoginId(reqgetUserpush.getUserId());
			userpushsetting.setUopsId(ToolUtil.getUid());
			userpushsetting.setOrderReminder(1);
			userpushsetting.setWeekendPush(1);
			userpushsetting.setRegularRouteConditions(1);
			super.userpushSettingDao.save(userpushsetting);
		}

		ResgetUserpush resgetUserpush = new ResgetUserpush();
		resgetUserpush.setOrderReminder(userpushsetting.getOrderReminder());
		resgetUserpush.setWeekendPush(userpushsetting.getWeekendPush());
		resgetUserpush.setRegularRouteConditions(userpushsetting.getRegularRouteConditions());
		dataResponse.setResponseBody(resgetUserpush);
		setStatus(dataResponse, SystemCode.SUCCESS);
		
	}

	/**
	 * @Title: initUserRoute
	 * @Description: 初始化用户路线(数据专用)
	 * @param userroute 
	 * @author yuHaiQing
	 * @return void    返回类型
	 * @throws
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public void initUserRoute(Userroute userroute) {

		try {
			super.userRouteDao.save(userroute);
		} catch (Exception e) {
			log.error("初始化用户路线出现异常  类：" + this.getClass() + " initUserRoute()", e);
		}

	}

	/**
	 * @Title: getUserRouteList
	 * @Description: 获取用户路线表中的全部用户Id
	 * @author yuHaiQing
	 * @return List<Userroute>    返回类型
	 */
	@Override
	@Transactional(readOnly = true)
	public List<Object[]> getUserRouteList() {

		return super.userRouteDao.getUserRouteList();
	}

}
